from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from backend.routes import alarms

app = FastAPI(title="网络云工作台告警分析报表系统", description="告警分析和管理系统", version="1.0.0")

# 配置CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 包含路由
app.include_router(alarms.router)

@app.get("/")
async def root():
    return {
        "message": "网络云工作台告警分析报表系统 API",
        "version": "1.0.0",
        "docs": "/docs",
        "frontend": "请单独启动前端服务"
    }

@app.get("/health")
async def health_check():
    return {"status": "healthy"}

if __name__ == "__main__":
    import uvicorn
    uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)